/**
 * precedence.cpp is part of Gedule.
 *
 * Gedule is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gedule is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Gedule.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "precedence.h"
#include "../../../utils/visitor/visitor.h"
#include <sstream>

const std::string Precedence::PRECEDENCE_STR = "Precedence";
const std::string Precedence::TASK_STR       = "task";
const std::string Precedence::BEFORE_STR     = "before";

///////////////////////////////////////////////////////////////
Precedence::Precedence( const std::string & a_taskBefore, const std::string & a_taskAfter ) :
    ModelConstraint(),
    m_taskBefore( a_taskBefore ),
    m_taskAfter( a_taskAfter )
{
}

///////////////////////////////////////////////////////////////
void Precedence::Accept( Visitor * a_visitor, bool )
{
    if( a_visitor )
        a_visitor->Visit( this );
}

///////////////////////////////////////////////////////////////
std::string Precedence::Print() const
{
    std::ostringstream strStream;
    strStream << PRECEDENCE_STR << ": "
              << TASK_STR << " \"" <<  m_taskBefore << "\" "
              << BEFORE_STR << " "
              << TASK_STR << " \"" <<  m_taskAfter << "\"";

    return strStream.str();

}

///////////////////////////////////////////////////////////////
const std::string & Precedence::TaskBefore() const
{
    return m_taskBefore;
}

///////////////////////////////////////////////////////////////
const std::string & Precedence::TaskAfter() const
{
    return m_taskAfter;
}
